package function;

import java.util.ArrayList;

public class Cos extends Function {
	private Function cosFunction;

	public Cos(Function f) {
		cosFunction = f;
	}

	public Function getCosFunction() {
		return cosFunction;
	}

	public void setCosFunction(Function cosFunction) {
		this.cosFunction = cosFunction;
	}

	public double evaluate(double x) {
		return Math.cos(cosFunction.evaluate(x));
	}

	public Function differentiate() {
		ArrayList<Function> result = new ArrayList<Function>();
		result.add(new Constant(-1));
		result.add(cosFunction.differentiate());
		result.add(new Sin(cosFunction));
		return new Multiply(result);
	}

	public String toString() {
		return "cos(" + cosFunction.toString() + ")";
	}
}
